<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // ES6函数相关   
    // 1. 函数参数默认值  

    // ES5
    // 给函数参数设置默认值
    /* function add(a, b) { 
        a = a == undefined ? 0 : a;
        b = b == undefined ? 0 : b;

        console.log(a,b);
        return a + b;
    }
    // console.log(add(1,2));
    console.log(add()); */


    // ES6
    function add(a = 0, b = 0) { 
        console.log(a,b);
        return a + b;
    }
    // console.log(add());
    // console.log(add(1,2));
    console.log(add(1));









</script>

</html>